﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PTP.Core;
using System.IO;

namespace PTP.TestUtil
{
  public static class ContainerUtil
  {
    public static byte[] GetBytes(this Container container)
    {
      using (MemoryStream ms = new MemoryStream())
      {
        container.Write(ms);
        return ms.ToArray();
      }
    }

    public static void WriteBytes(this ContainerHeader header, byte[] buffer)
    {
      using (MemoryStream ms = new MemoryStream(buffer.Length))
      {
        header.Write(ms);
        ms.ToArray().CopyTo(buffer, 0);
      }
    }
  }
}
